package com.yanqu.road.server.cmd.activity.doublespring;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.DoubleSpringProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.doublespring.DoubleSpringActivityModule;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = DoubleSpringProto.DoubleSpringTravelReqMsg.class, respMsg = DoubleSpringProto.DoubleSpringTravelRespMsg.class)
@Cmd(code = Protocol.S_DOUBLE_SPRING_TRAVEL,desc = "踏春游记-出行")
public class DoubleSpringTravelCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DoubleSpringProto.DoubleSpringTravelReqMsg reqMsg = DoubleSpringProto.DoubleSpringTravelReqMsg.parseFrom(packet.getBytes());
        try {
            player.getModule(DoubleSpringActivityModule.class).travel(reqMsg);
        } catch (BusinessException e) {
            DoubleSpringProto.DoubleSpringTravelRespMsg.Builder respMsg = DoubleSpringProto.DoubleSpringTravelRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_DOUBLE_SPRING_TRAVEL, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
